package com.xkdx.caipiao.presistence.historynewaccount;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xkdx.caipiao.module.network.AbsModule;

public class HistoryNewAccountQueryModule extends AbsModule {
	public List<HistoryNewAccountQueryInfo> list;
	
	@Override
	public void parseData() throws Exception {
		try {
			backJson = (JSONArray) result;
			for (int i = 0; i < backJson.size(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("GetAccountList_New")) {
					parseHistoryQuery(jsonObj.getJSONArray("DetailInfo"));
				}

			}
		} catch (Exception e) {
			// to do define a exception include all parseException
			throw e;
		}

	}
	

	private void parseHistoryQuery(JSONArray person) throws Exception {
		try {
			list=new ArrayList<HistoryNewAccountQueryInfo>();
			
			for(int i=0;i<person.size();i++){
				JSONObject obj=person.getJSONObject(i);
				HistoryNewAccountQueryInfo info=new HistoryNewAccountQueryInfo();
				info.setCtime(obj.getString("ctime"));
				info.setId(obj.getString("id"));
				info.setMoney(obj.getString("money"));
				info.setOid(obj.getString("orderid"));
				info.setType(obj.getString("type"));
				info.setUid(obj.getString("uid"));
				info.setDetail(obj.getString("detail"));
				list.add(info);
				
			}
			
		} catch (Exception e) {
			
			throw e;
		}

	}
}
